﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace AdvanceLib.UI
{
    public class BasePanel : Panel
    {
        #region Constructors
        public BasePanel()
        {
            this.DoubleBuffered = true;
            this.ResizeRedraw = true;

            this.Animator = new Animator();
            this.Animator.AnimateFrame += new EventHandler(Animator_AnimateFrame);

            this._renderEngine = new RenderEngine();

            this._invalidate = new BaseControl.NoArgumentsVoid(this.Invalidate);
        }
        #endregion

        #region Fields
        public Animator Animator = null;

        private RenderEngine _renderEngine = null;
        private BaseControl.NoArgumentsVoid _invalidate;
        #endregion

        #region Properties
        [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public RenderEngine RenderEngine
        {
            get { return _renderEngine; }
            set { _renderEngine = value; }
        }
        #endregion

        #region Event Handlers
        void Animator_AnimateFrame(object sender, EventArgs e)
        {
            this.Invoke(this._invalidate); //Verhindert Multithreading Rendering
        }
        #endregion
    }
}
